﻿/*
 * ========================================================================
 * Copyright(c) 2007-2012 情留メ蚊子, All Rights Reserved.
 * Welcom use the LiteFetion.
 * See more information,Please goto http://www.94qing.com
 * ========================================================================
 * 
 * 作 者：情留メ蚊子
 * Q  Q: 540644769
 * 邮 箱：qlwz@qq.com
 * 网 址：http://www.94qing.com
 * ========================================================================
*/
using System;
using LiteFetion.Model;
using Newtonsoft.Json.Linq;

namespace LiteFetion.Notify
{
    /// <summary>
    /// 添加好友请求
    /// </summary>
    public class BuddyInviteNotify
    {
        public BuddyInviteNotify(FetionClient client, JObject data)
        {
            this.FetionClient = client;
            this.Buddy = new Buddy();
            this.Desc = data.Value<string>("desc");
            this.DateTime = data.Value<string>("at").ToDateTime().AddHours(+8);//不知道为什么与服务器相差8小时
            int phrid = data.Value<int>("phrid");
            this.Buddy.UserId = data.Value<int>("uid");
            this.Buddy.Uri = data.Value<string>("uri");
            this.Buddy.Relation = Relation.STRANGER;
            this.FetionClient.BuddyList.Add(Buddy);
            this.Desc = "你好，我是" + this.Desc + "，";
            switch (phrid)
            {
                case 0:
                    this.Desc += "正在用中国移动飞信业务，想加你为好友。";
                    break;
                case 1:
                    this.Desc += "想加你为飞信好友，方便咱们联系。";
                    break;
                case 2:
                    this.Desc += "飞信挺好用的，想加你为好友。";
                    break;
                case 3:
                    this.Desc += "希望你成为我的飞信好友，常联系。";
                    break;
                case 4:
                    this.Desc += "成为我的飞信好友，能免费给你发短信。";
                    break;
                default:
                    break;
            }
            Event.OnBuddyInviteNotify(this);
        }

        /// <summary>
        /// FetionClient
        /// </summary>
        public FetionClient FetionClient { get; private set; }

        /// <summary>
        /// 请求添加用户为好友的对象
        /// </summary>
        public Buddy Buddy { get; private set; }

        /// <summary>
        /// 说明,我是 xxx
        /// </summary>
        public string Desc { get; private set; }

        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime DateTime { get; private set; }

        public override string ToString()
        {
            return "BuddyInviteNotify [Buddy=" + this.Buddy.DisplayName + ", Desc=" + this.Desc + ", DateTime=" + this.DateTime + "]";
        }
    }
}
